﻿<dialogs:DialogWindow x:Class="Modules.Albums.Views.AlbumSearchDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="clr-namespace:Common.Controls.Controls;assembly=Common.Controls"
             xmlns:commonControls="clr-namespace:Common.Controls.Controls;assembly=Common.Controls"
             xmlns:commands="clr-namespace:Common.Commands;assembly=Common.Commands"
             xmlns:dialogs="clr-namespace:Common.Dialogs;assembly=Common.Dialogs"
             xmlns:pagerCommands="clr-namespace:Common.Controls.Controls;assembly=Common.Controls"
             xmlns:prismCommands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
             mc:Ignorable="d" 
             WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize"
             Background="Transparent" WindowStartupLocation="CenterScreen"
             WindowResult="{Binding DialogResult}" commands:Loaded.Command="{Binding ViewLoadedCommand}"
             Height="505" Width="619">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="LocalResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid x:Name="LayoutRoot" 
          controls:BusyIndicatorBehavior.AddMargins="True" 
          controls:BusyIndicatorBehavior.BusyState="{Binding IsBusy}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border x:Name="HeaderBorder" Grid.Row="0" BorderThickness="2,2,2,0" CornerRadius="10,10,0,0" BorderBrush="Black" Background="SteelBlue"
                MouseDown="HeaderBorder_MouseDown">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <StackPanel HorizontalAlignment="Left" Grid.Column="0">
                    <TextBlock Text="Search album" Style="{StaticResource DialogHeaderTextStyle}"/>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Grid.Column="1">
                    <Button VerticalAlignment="Center" Margin="8" Style="{StaticResource CloseButtonStyle}"
                            prismCommands:Click.Command="{Binding CancelSaveCommand}"
                            >
                        <Button.Content>
                            <Image Source="/Common.Dialogs;component/Images/305_Close_16x16_72.png" Width="12" Height="12"/>
                        </Button.Content>
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
        <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" BorderBrush="Black" Background="LightGray">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid x:Name="ContentLayout" Grid.Row="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <commonControls:FilterControl Grid.Row="0" Margin="4"
                                          FilterFields="{Binding Fields}"
                                          GroupingEnabled="{Binding GroupingEnabled}"
                                          SelectedFilterField="{Binding SelectedField,Mode=TwoWay}"
                                          SelectedFilterValue="{Binding SelectedValue,Mode=TwoWay}"
                                          ItemContainerStyle="{StaticResource GeneralComboBoxItemStyle}"/>
                    <ListView x:Name="AlbumsListView" Grid.Row="1"
                      commands:MouseDoubleClick.Command="{Binding SelectAlbumCommand}"
                      ItemsSource="{Binding AlbumsCollection}" ItemTemplate="{StaticResource AlbumTemplate}"
                      ItemContainerStyle="{StaticResource GeneralListViewItemStyle}"
                      SelectedItem="{Binding CurrentAlbum}"/>
                    <Grid Grid.Row="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <commonControls:DataPager Grid.Column="0" Margin="4"
                                  HorizontalAlignment="Left"
                                  ItemsPerPage="{Binding LoadOptions.MaxResults}" VisiblePagesCount="3" TotalItems="{Binding AlbumsCount}"
                                  pagerCommands:PageChanged.Command="{Binding PageChangedCommand}"/>
                        <StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Margin="4">
                            <Button x:Name="OkButton" Content="Ok" Width="75" IsDefault="True" Margin="6"
                                    Style="{StaticResource DialogButtonStyle}"
                                    prismCommands:Click.Command="{Binding SaveCommand}"/>
                            <Button x:Name="CancelButton" Content="Cancel" Width="75" IsDefault="True" Margin="6"
                                    Style="{StaticResource DialogButtonStyle}"
                                    prismCommands:Click.Command="{Binding CancelSaveCommand}"/>
                        </StackPanel>
                    </Grid>

                </Grid>
                
            </Grid>
        </Border>
    </Grid>
</dialogs:DialogWindow>
